<template>
	<view class="content">
		<view class="swiper">
			<uni-swiper-dot @clickItem=clickItem :info="bannerList" :current="current" field="content" :mode="mode"
				:dotsStyles="dotStyle">
				<swiper class="swiper-box" @change="change" :circular="true" :current="swiperDotIndex" autoplay="true"
					:interval="2000" :duration="500">
					<swiper-item v-for="(item ,index) in bannerList" :key="index">
						<view class="swiper-img">
							<!-- {{item.content}} -->
							<image :src="item.logo" mode=""></image>
						</view>
					</swiper-item>
				</swiper>
			</uni-swiper-dot>
		</view>
		<view class="list-text">
			<view class="image-text" v-for="(item, index) in articledata.articleTypeList" :key="index"
				@click="getligtenterpren(item.name,item.id,index)">
				<image class="image" :src="item.logo" mode=""></image>
				<view class="text">
					{{item.name}}
				</view>
			</view>
		</view>
		<view class="shei">
			<image class="image" src="../../static/image/sheuzhengmuzheng.png" mode=""></image>
		</view>
		<view class="water" v-show="articledata.recommendArticleTypeList && articledata.recommendArticleTypeList.length >= 1">
			<view class="water-tito">
				<view class="way">
					{{articledata.recommendArticleTypeList[0].name}}
				</view>
				<view class="more" @click="entrepren('水之道',articledata.recommendArticleTypeList[0].id)">
					更多
					<uni-icons type="right" size="15" color="#616366"></uni-icons>
				</view>
			</view>
			<view class="corten" v-for="(item,index) in articledata.recommendArticleTypeList[0].articleList"
				:key="index" @click="getdetails(item.id)">
				<view class="videotext">
					{{item.name}}
				</view>
				<view class="time">
					{{item.createTime}}
				</view>
			</view>
		</view>
		<view class="lightEmployment">
			<view class="light" v-show="articledata.recommendArticleTypeList && articledata.recommendArticleTypeList.length >= 2">
				<view class="achieve" @click="entrepren('轻创业',articledata.recommendArticleTypeList[1].id)">
					{{articledata.recommendArticleTypeList[1].name}}
					<uni-icons color="#616366" class="icons" type="right" size="20"></uni-icons>
				</view>
				<view class="achieve-text" v-for="(item,index) in articledata.recommendArticleTypeList[1].articleList"
					:key="index" @click="getdetails(item.id)">
					{{item.name}}
				</view>
			</view>
			<view class="light employment" v-show="articledata.recommendArticleTypeList && articledata.recommendArticleTypeList.length >= 3">
				<view class="achieve ployment" @click="entrepren('轻就业',articledata.recommendArticleTypeList[2].id)">
					{{articledata.recommendArticleTypeList[2].name}}
					<uni-icons color="#616366" class="icons" type="right" size="20"></uni-icons>
				</view>
				<view class="achieve-text" v-for="(item,index) in articledata.recommendArticleTypeList[2].articleList"
					:key="index" @click="getdetails(item.id)">
					{{item.name}}
				</view>
			</view>
		</view>
		<view class="commodityList">
			<view class="commodity" v-for="(item,index) in goodsList" :key="item.id">
				<view class="salescommodity">
					<view class="sales">
						{{item.name}}
					</view>
					<view class="dity" @click="getmore">
						更多
						<uni-icons type="right" size="15" color="#616366"></uni-icons>
					</view>
				</view>
				<view class="corten-list">
					<view class="corten" v-for="(item2,index2) in item.goodsList" :key="item2.id" @click="getProductDetails(item2)">
						<view class="image">
							<image class="image" :src="item2.logo" mode=""></image>
						</view>
						<view class="text-water">
							<view class="textwater">
								{{item2.name}}
							</view>
							<view class="checkTheNumber">
								{{item2.name}}
								<!-- <view class="water-number ">
									<view class="number">
										1
									</view>
									<view class="waterThe">
										水类数量
									</view>
								</view>
								<view class="lineView"></view>
								<view class="water-number">
									<view class="number">
										1
									</view>
									<view class="waterThe">
										取水点数
									</view>
								</view> -->
							</view>
							<view class="money">
								<view class="two">
									<text class="moneyIcon">￥</text>{{item2.money}}
									<!-- <text class="moneyMonth">/月</text> -->
								</view>
								<view class="three">
									￥{{item2.originalMoney}}
									<!-- /月 -->
								</view>
							</view>
							<view class="service">
								已销售{{item2.sales}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bottom">
			<text>没有更多内容了</text>
		</view>
		<view class="crown" v-show="crown" @click="getcrown">
			<image src="../../static/image/zhiding.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bannerList: [],
				current: 0,
				mode: 'round',
				dotStyle: {
					backgroundColor: 'rgba(255,255,255,0.5)',
					border: '1px rgba(0, 0, 0, .3) solid',
					color: '#fff',
					selectedBackgroundColor: '#FFFFFF',
					selectedBorder: '1px #FFFFFF solid'
				},
				swiperDotIndex: 0,
				articledata: [],
				status: 'more',
				isHaveMore: true,
				crown: false,
				goodsList: [],
			}
		},
		onLoad() {
			this.getbanner()
			this.getarticle()
			this.getgoodsList()
		},
		onPageScroll(e) {
			if (e.scrollTop >= 400) {
				this.crown = true
			} else {
				this.crown = false
			}
		},
		onReachBottom() {
			if (!this.isHaveMore) {
				return
			}
		},
		methods: {
			//文章详情
			getdetails(id) {
				uni.navigateTo({
					url: "/subpackageA/pages/home/details?id=" + id
				})
			},
			change(e) {
				this.current = e.detail.current
			},
			clickItem(e) {
				this.swiperDotIndex = e
			},
			//跳转文章详情
			entrepren(text, id) {
				uni.navigateTo({
					url: "/subpackageA/pages/home/lightEntrepreneurship?titoText=" + text + "&id=" + id
				})
			},
			//分类跳转文章或者商城
			getligtenterpren(text, id,inx) {
				if (text == "水之道" || text == "轻创业" || text == "轻就业") {
					uni.navigateTo({
						url: "/subpackageA/pages/home/lightEntrepreneurship?titoText=" + text + "&id=" + id
					})
				}
				if (inx >= 3) {
					uni.switchTab({
						url:"/pages/mall/mall"
					})
				}
			},
			//回到顶部
			getcrown() {
				uni.pageScrollTo({
					scrollTop: 0, // 滚动到页面的目标位置  这个是滚动到顶部, 0 
					duration: 100 // 滚动动画的时长
				})
			},
			//获取轮播图列表
			getbanner() {
				this.$request.get("/water-platform-app-api/home/home/banner").then(res => {
					console.log(res, '获取轮播图列表');
					this.bannerList = res.data
				})
			},
			//文章分类和推荐分类
			getarticle() {
				this.$request.get("/water-platform-app-api/home/home/article").then(res => {
					console.log(res, '文章分类和推荐分类');
					this.articledata = res.data
				})
			},
			//推荐商品列表
			getgoodsList() {
				this.$request.get("/water-platform-app-api/home/home/goodsList").then(res => {
					console.log(res, '推荐商品列表');
					this.goodsList = res.data
				})
			},
			//跳转商品详情
			getProductDetails(e){
				uni.navigateTo({
					url:"/subpackageA/pages/mall/productDetails?id=" + e.id
				})
			},
			//商品更多
			getmore(){
				uni.switchTab({
					url:"/pages/mall/mall"
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		min-height: 100vh;
		background: #F4F5F6;
		overflow: auto;
		position: relative;

		.swiper {
			height: 422rpx;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			// background-color: red;
			// padding-top: 88rpx;
			box-sizing: border-box;

			.swiper-box {
				height: 422rpx;
			}

			.swiper-img {
				display: block;
				width: 100%;
				height: 422rpx;
				text-align: center;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.list-text {
			text-align: center;
			padding: 32rpx 0;
			box-sizing: border-box;
			display: flex;
			flex-wrap: wrap;

			.image-text {
				width: 25%;
				margin-bottom: 32rpx;

				.image {
					width: 96rpx;
					height: 96rpx;
					border-radius: 0rpx 0rpx 0rpx 0rpx;
				}

				.text {
					font-size: 24rpx;
					color: #303332;
				}
			}
		}

		.shei {
			height: 168rpx;
			margin: 0 30rpx;

			.image {
				width: 100%;
				height: 100%;
			}
		}

		.water {
			margin: 32rpx 30rpx;
			background-color: #FFF;
			border: 2rpx solid #C7E0FA;
			border-radius: 12rpx;
			box-shadow: inset 0rpx 0rpx 60rpx 0rpx #E1E9FA;

			.water-tito {
				height: 92rpx;
				position: relative;
				overflow: hidden;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.way {
					font-size: 32rpx;
					margin-left: 96rpx;
					font-weight: 700;
					font-family: PingFang SC, PingFang SC;

				}

				.more {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					color: #616366;
					margin-right: 24rpx;
				}
			}

			.corten {
				height: 64rpx;
				display: flex;
				justify-content: space-between;
				padding: 0 24rpx;
				box-sizing: border-box;
				border-bottom: 2rpx solid #F1F2F2;
				margin: 24rpx 0;

				.videotext {
					font-weight: 600;
					font-size: 28rpx;
					color: #2E3033;
				}

				.time {
					font-size: 24rpx;
					color: #B1B2B2;
				}
			}

			.corten:last-child {
				border-bottom: none;
			}

			.water-tito::after {
				content: "";
				width: 64rpx;
				height: 64rpx;
				border-radius: 50%;
				background: linear-gradient(139deg, rgba(225, 237, 250, 0) 0%, #2590FA 100%);
				position: absolute;
				left: -10rpx;
				top: -10rpx;
			}

			.water-tito::before {
				content: "";
				width: 36rpx;
				height: 36rpx;
				border-radius: 50%;
				background: linear-gradient(139deg, rgba(225, 237, 250, 0) 0%, #2590FA 100%);
				position: absolute;
				left: 35rpx;
				top: 20rpx;
			}
		}

		.lightEmployment {
			display: flex;
			justify-content: space-between;
			padding: 0 30rpx;
			box-sizing: border-box;

			.light {
				width: 48.5%;
				// height: 548rpx;
				background: #FFFFFF;
				box-shadow: inset 0rpx 0rpx 60rpx 0rpx #FAEBE1;
				border-radius: 16rpx;
				border: 1rpx solid #FACEAF;
				position: relative;
				overflow: hidden;


				.achieve {
					font-weight: 600;
					font-size: 32rpx;
					color: #14171A;
					margin: 24rpx 0 40rpx 96rpx;
					display: flex;
					justify-content: space-between;

					.icons {
						margin-right: 34rpx;
					}
				}

				.achieve-text {
					height: 64rpx;
					padding: 0 24rpx;
					box-sizing: border-box;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
					border-bottom: 2rpx solid #F1F2F2;
					margin-bottom: 24rpx;
				}

				.achieve-text:last-child {
					border-bottom: none;
				}
			}

			.employment {
				box-shadow: inset 0rpx 0rpx 60rpx 0rpx #E1E9FA;
				border: 2rpx solid #AFC8FA;

				.ployment {
					display: flex;
					justify-content: space-between;

					.icons {
						margin-right: 34rpx;
					}
				}
			}

			.light::after {
				content: "";
				width: 64rpx;
				height: 64rpx;
				border-radius: 50%;
				background: linear-gradient(139deg, rgba(250, 235, 225, 0) 0%, #FA6B05 100%);
				position: absolute;
				left: -10rpx;
				top: -10rpx;
			}

			.light::before {
				content: "";
				width: 36rpx;
				height: 36rpx;
				border-radius: 50%;
				background: linear-gradient(139deg, rgba(250, 235, 225, 0) 0%, #FA6B05 100%);
				position: absolute;
				left: 35rpx;
				top: 20rpx;
			}

			.employment::after {
				content: "";
				width: 64rpx;
				height: 64rpx;
				border-radius: 50%;
				background: linear-gradient(139deg, rgba(250, 235, 225, 0) 0%, #256CFA 100%);
				position: absolute;
				left: -10rpx;
				top: -10rpx;
			}

			.employment::before {
				content: "";
				width: 36rpx;
				height: 36rpx;
				border-radius: 50%;
				background: linear-gradient(139deg, rgba(225, 233, 250, 0) 0%, #256CFA 100%);
				position: absolute;
				left: 35rpx;
				top: 20rpx;
			}

		}

		.commodityList {

			.commodity {
				width: 690rpx;
				// height: 1280rpx;
				// background-color: red;
				margin: 48rpx auto 32rpx;

				.salescommodity {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: 6rpx 6rpx 32rpx 28rpx;

					.sales {
						font-weight: 600;
						font-size: 36rpx;
						color: #14171A;
						position: relative;
					}

					.dity {
						font-size: 24rpx;
						color: #616366;
						display: flex;
						align-items: center;
					}

					.sales::before {
						content: "";
						width: 56rpx;
						height: 56rpx;
						background: linear-gradient(125deg, #2590FA 0%, rgba(225, 237, 250, 0) 100%);
						border-radius: 50%;
						position: absolute;
						left: -28rpx;
						top: -6rpx;
					}
				}

				.corten-list {

					.corten {
						// height: 280rpx;
						background: #FFFFFF;
						display: flex;
						align-items: center;
						border-radius: 16rpx 16rpx 16rpx 16rpx;
						padding: 24rpx;
						box-sizing: border-box;
						margin-top: 24rpx;

						.image {
							width: 232rpx;
							height: 232rpx;
							border-radius: 12rpx 12rpx 12rpx 12rpx;
						}

						.text-water {
							margin-left: 16rpx;

							.textwater {
								font-weight: 600;
								font-size: 32rpx;
								color: #2E3033;
								overflow: hidden;
								text-overflow: ellipsis;
								display: -webkit-box;
								-webkit-line-clamp: 2;
								-webkit-box-orient: vertical;
							}

							.checkTheNumber {
								width: 350rpx;
								font-size: 24rpx;
								color: #616366;
								margin-top: 16rpx;
								white-space: nowrap;
								overflow: hidden;
								text-overflow: ellipsis;
								// display: flex;
								// position: relative;
								// align-items: center;

								.water-number {
									display: flex;
									flex-direction: column;
									align-items: center;
									justify-content: center;

									.number {
										font-weight: 600;
										font-size: 32rpx;
										color: #2E3033;
									}

									.waterThe {
										font-size: 24rpx;
										color: #616366;
									}
								}

								.lineView {
									width: 2rpx;
									height: 48rpx;
									background-color: #E4E5E6;
									margin: 0 48rpx;
								}
							}

							.money {
								display: flex;
								align-items: center;
								margin-top: 16rpx;

								.two {
									font-size: 36rpx;
									color: #FA6B05;
									font-weight: 700;
									display: flex;
									justify-content: center;
									align-items: center;

									.moneyIcon {
										font-size: 28rpx;
									}

									.moneyMonth {
										font-size: 24rpx;
										color: #616366;
										font-weight: 400;
									}
								}

								.three {
									margin-left: 16rpx;
									font-size: 24rpx;
									color: #B1B2B2;
									text-decoration: line-through;
								}
							}

							.service {
								margin-top: 16rpx;
								font-size: 20rpx;
								color: #B1B2B2;
								margin-top: 8rpx;
							}

						}
					}

					.corten:first-child {
						margin-top: 0;
					}
				}
			}
		}

		.bottom {
			text-align: center;
			padding-bottom: 32rpx;
			box-sizing: border-box;

			text {
				font-size: 24rpx;
				color: #B1B2B2;
			}
		}

		.crown {
			position: fixed;
			right: 32rpx;
			top: 80%;

			image {
				width: 100%;
				height: 100%;
				width: 88rpx;
				height: 88rpx;
			}
		}
	}
</style>